package com.sos.core
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	public class DispatcherDataObject extends DataObject implements IEventDispatcher
	{
		
		private var _dispatchEnabled:Boolean;
		private var _dispatcher:EventDispatcher;
		
		
		public function DispatcherDataObject()
		{
			_dispatchEnabled = true;
			_dispatcher = new EventDispatcher(this);
		}
		
		public function get dispatchEnabled():Boolean
		{
			return _dispatchEnabled;
		}
		
		public function set dispatchEnabled(value:Boolean):void
		{
			_dispatchEnabled = value;
		}
		
		public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void
		{
			_dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
		}
		
		public function dispatchEvent(event:Event):Boolean
		{
			if (_dispatchEnabled) return _dispatcher.dispatchEvent(event);
			return false;
		}
		
		public function hasEventListener(type:String):Boolean
		{
			return _dispatcher.hasEventListener(type);
		}
		
		public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void
		{
			_dispatcher.removeEventListener(type, listener, useCapture);
		}
		
		public function willTrigger(type:String):Boolean
		{
			if (_dispatchEnabled) return _dispatcher.willTrigger(type);
			return false;
		}
		
	}
}